package edu.spec.chenli.Filter;

import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.Date;

//@WebFilter(filterName = "LogFilter",urlPatterns = "/ts")
public class LogFilter implements Filter {
    public void destroy() {
    }

    public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws ServletException, IOException {
        HttpServletRequest r= (HttpServletRequest)req;
        // HttpSession session = r.getSession(true);
        // String username = (String)session.getAttribute("username");
        java.lang.String path = r.getServletPath();
        System.out.println("LogFilter:用户访问时间："+ new Date()+"用户访问地址："+path);
        chain.doFilter(req, resp);
        System.out.println("");

    }

    public void init(FilterConfig config) throws ServletException {

    }

}
